package org.sgx.gwteditors.testgallery.gallery.simple;

import java.util.Map;

import org.sgx.gwteditors.client.editor.event.EditorValueChangeEvent;
import org.sgx.gwteditors.client.editor.event.ValueChangeListener;
import org.sgx.gwteditors.client.impl1.basetypes.SelectionList;
import org.sgx.gwteditors.client.impl1.complex.SelectionListMultipleSelEditor;
import org.sgx.gwteditors.client.impl1.complex.SelectionListSingleSelEditor;
import org.sgx.gwteditors.client.util.TestUtil;
import org.sgx.gwteditors.testgallery.gallery.Test;
import org.sgx.gwteditors.testgallery.gallery.TestResources;

import com.google.gwt.resources.client.ExternalTextResource;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Panel;

public class SimpleSelectionListMultipleSelEditorTest implements Test {	

@Override
/*---begintestmaincode---*/
public void test(Panel parent) {	
	String[] allOptions = {"uno", "dos", "tres", "cuatro"}, 
			selection = {"dos", "cuatro"}; 	
	SelectionList<String> selList1 = new SelectionList<String>(allOptions, selection);	
	final SelectionListMultipleSelEditor<String> ed1 = new SelectionListMultipleSelEditor<String>();
	ed1.load(selList1);
	ed1.addValueChangeListener(new ValueChangeListener<SelectionList<String>>() {			
		@Override
		public void notifyValueChange(	EditorValueChangeEvent<SelectionList<String>> evt) {
			Window.alert("selection detected: "+ed1.flush());
		}
	});
	parent.add(ed1.getWidget()); 
}
/*---endtestmaincode---*/
	
	//test stuff
	@Override
	public String getName() {
		return "SimpleSelectionListMultipleSelEditorTest";
	}

	@Override
	public String[] getTags() {		
		return null;
	}

	@Override
	public String getDescription() {
		return "SimpleSelectionListMultipleSelEditorTest";
	}
	@Override
	public Map<String, ExternalTextResource> getJavaSources() {
		return TestUtil.getResource(getName(), TestResources.INSTANCE.SimpleSelectionListMultipleSelEditorTest());
	}
	
}
